package com.example.day04.exercise;

import com.sun.org.apache.xpath.internal.operations.Or;

import java.util.Date;

public class CustomerBiz {



    //数组扩容
    public   void expansion(Ord [] arr){
        Ord [] ords=new Ord[arr.length];

        for(int i=0;i<arr.length;i++){
            ords[i]=arr[i];
        }
        arr=ords;
    }

    //添加订单信息
    public  void addOrderMessage(Customer c,Ord order){
        int size=c.getSize();
        if(order==null){

            return;
        }

        Ord [] ords=c.getArrs();
        ords[size]=order;

        if(size>ords.length-1){
            expansion(ords);
        }
        c.setArrs(ords);

    }


}

class    TestCustomer{
    public static void main(String[] args) {

        Customer customer=new Customer();
        customer.setMax(10);
        customer.setSize(0);
        Ord ord1=new Ord(1,11,12.3,new Date());
        Ord ord2=new Ord(2,22,22.3,new Date());
        Ord ord3=new Ord(3,33,32.3,new Date());


        CustomerBiz customerBiz=new CustomerBiz();
        customerBiz.addOrderMessage(customer,ord1);
        customerBiz.addOrderMessage(customer,ord2);
        customerBiz.addOrderMessage(customer,ord3);

        customer.showorderarr();

    }
}
